<#-- 导入模版定义文件-->
<#include "../template/template_editPage.ftl">
<@edit title="家族视频管理">

<body class="input">
<script type="text/javascript">
	$().ready( function() {	
		var $validateErrorContainer = $("#validateErrorContainer");
		var $validateErrorLabelContainer = $("#validateErrorContainer ul");
		var $validateForm = $("#inputForm");
		var $tab = $("#tab");
	
		// Tab效果
		$tab.tabs(".tabContent", {
			tabs: "input"
		});
		
		// 表单验证
		$validateForm.validate({
			errorContainer: $validateErrorContainer,
			errorLabelContainer: $validateErrorLabelContainer,
			wrapper: "li",
			errorClass: "validateError",
			ignoreTitle: true,
			rules: {
				"videoInfo.videoTitle": {
						required: true,
						maxlength:30
				},
				"videoInfo.activityTitle": {
						required: true
				},
				"videoInfo.videoPath": {
						required: true,
						url: true,
						maxlength:500
				},
				"videoInfo.videoDesc": {
						maxlength:200
				}
				
			},
			messages: {
				"videoInfo.videoTitle": {
						required: "请输入视频标题",
						maxlength: "视频标题必须在30个字符以内"
				},
				"videoInfo.activityTitle": {
						required: "请选择活动标题"
				},
				"videoInfo.videoPath": {
						required: "请输入视频地址",
						url: "请输入合法的视频地址",
						maxlength: "视频地址必须在500个字符以内"
				},
				"videoInfo.videoDesc": {
						maxlength: "视频描述必须在200个字符以内"
				} 
			},
			submitHandler: function(form) {
				$(form).find(":submit").attr("disabled", true);
				form.submit();
			}
		});
		<#if actionErrors??&&(actionErrors?size > 0)>
			$.dialog({type: "warn", content: "<#list errorMessages as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 3000});
		</#if>
		<#if actionMessages??&&(actionMessages?size > 0)>
			$.dialog({type: "success", content: "<#list actionMessages as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 5000});
		</#if>
    
	});
	
function showDiv(picId,imgdiv,imgShow){
   		new uploadPreview({ UpBtn: picId, DivShow: imgdiv, ImgShow: imgShow });
	}
	
	function clearImg(imgId,imgShow){
		var obj = document.getElementById(imgId) ;   
		obj.outerHTML=obj.outerHTML;  
		
		$('#'+imgShow).attr("src", "");
	}
	

</script>
	<div class="body">
		<div class="inputBar">
			<h1><span class="icon">&nbsp;</span><#if videoId??>编辑家族视频<#else>新增家族视频</#if></h1>
		</div>
		<div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
			<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
				<ul></ul>
			</div>
		</div>		
		<form id="inputForm" class="validate" action="<#if videoId??>${web_base}/go/video!edit.htm<#else>${web_base}/go/video!save.htm</#if>" method="post" enctype="multipart/form-data">
			<input type="hidden" name="videoInfo.videoId" value="${(videoInfo.videoId)!}"/>
			<table class="inputTable tabContent">
				<tr>
					<th>
						视频标题：
					</th>
					<td>
						<input type="text" id="" name="videoInfo.videoTitle" class="formText required" value="${(videoInfo.videoTitle)!}" />
						<label id="labelUrl" class="requireField">*</label>
					</td>
				</tr>
				<tr>
					<th>
						视频地址：
					</th>
					<td>
						<input type="text" id="" name="videoInfo.videoPath" class="formText required defaultInvalid url" value="${(videoInfo.videoPath)!}" />
						<label id="labelUrl" class="requireField">*</label>
					</td>
				</tr>
				<tr>
					<th>
						所属大类：
					</th>
					<td>
						<select name="videoInfo.bigClassId" class="{required: true}" style="font-size: 14px">
						    <option value="" >请选择</option>
							<#if bigClassList??>
                        	<#list bigClassList as obj>
	                            <option value="${obj.classId!}" <#if videoInfo?? && obj.classId == videoInfo.bigClassId>selected</#if>>
		                           <#if obj.className?? && obj.className?length gte 15>
			                                <#--//截取输出文字的长度-->
			                                ${obj.className?substring(0,15)}...
			                        <#else>
		                                ${(obj.className)!}
		                            </#if>
                               </option>
		                        </#list>
		                    </#if>
						</select>
						<label class="requireField">*</label>
					</td>
				</tr>
				<tr>
					<th>
						活动标题：
					</th>
					<td>
						<select name="videoInfo.activityTitle" class="{required: true}" style="font-size: 14px">
						    <option value="" >请选择</option>
							<#if activitys??>
                       		<#list activitys as obj>
	                            <option value="${obj.activityId!}" >
		                           <#if obj.activityTitle?? && obj.activityTitle?length gte 20>
			                                <#--//截取输出文字的长度-->
			                                ${obj.activityTitle?substring(0,20)}...
			                        <#else>
		                                ${(obj.activityTitle)!}
		                            </#if>
                               </option>
		                        </#list>
		                    </#if>
						</select>
						<label id="labelUrl" class="requireField">*</label>
					</td>
				</tr>
				<tr>
					<th>
						视频所属时间：
					</th>
					<td>
						<input type="text" id="videoTime" name="videoInfo.videoTime"
                          onclick="WdatePicker({skin:'whyGreen',startDate:'%y',dateFmt:'yyyy-MM-dd'})"
                           value="${(videoInfo.videoTime?string("yyyy-MM-dd"))!}" class="Wdate fixWidth" />
					</td>
				</tr>
				<tr>
					<th>
						视频封面：
					</th>
					<td>
					<div style="float:left">
    				<input type="file" id="videoCover" name="videoCover" value="添加图片" onclick="showDiv('videoCover','imgdiv1','imgShow1')"/>
						<div id="imgdiv1">
							<img id="imgShow1" width="160" height="100"  src="${(web_base + (videoInfo.videoCover))!}"/>
							<span class="spanLink" onclick="clearImg('imgdiv1','imgShow1')" title="删除">[删除]</span>
						</div>
					</div>
					</td>
				</tr>
				<tr>
					<th>
						视频描述：
					</th>
					<td>
						<textarea rows="8" cols="60" name="videoInfo.videoDesc" class="formText {}" >${(videoInfo.videoDesc)!}</textarea>
					</td>
				</tr>
			</table>
			<div class="buttonArea">
				<input type="submit" class="formButton" value="提  交" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回" hidefocus="true" />
			</div>
		</form>
	</div>
</body>
</@edit>